/*
 * lcmd_error.cpp
 *
 *  Created on: 27.06.2011
 *      Author: michael
 */

#include "lcmd_includes.h"

#include "lcmd_error.h"

LcmdError::LcmdError(int errornr,string file, int line)
{
	this->errornr = errornr;
	this->file = file;
	this->line = line;
}
LcmdError::~LcmdError()
{}

void LcmdError::logError(lcm::log::Logger *logger)
{
	logger->write(this->errorToText(),lcm::log::LOGGER_ERROR);
}

string LcmdError::errorToText()
{
	ostringstream os;
	os << "In: " << this->file << ":" << this->line;
	switch(this->errornr)
	{
		case lcm::error::NET_COULD_NOT_ACCEPT:
			os  << " Could not accept connection!";
		default:
			os << " No errormessage defined!";
	}

	os << " (Code: " << this->errornr << ")" << flush;

	return os.str();
}
